package we3d.animation 
{
	import we3d.animation.IChannel;
	import we3d.animation.KeyFrame;
	import we3d.animation.modifier.IModifier;
	
	/**
	* StaticChannel takes an array with frame values
	*/
	public class StaticChannel implements IChannel 
	{
		public function StaticChannel ( arr:Array = null ) {
			if(arr != null) {
				timeline = arr;
				totalframes = arr.length;
			}
		}
		public var loop:Boolean=true;
		public var totalframes:Number=0;
		public var timeline:Array;
		
		public function clearFrames () :void {}
		public function storeFrame (keyframe:Number=1, value:Number=0, ease_def:*=undefined) :void {}
		public function removeFrame (frame:Number=1) :Boolean { return false; }
		
		public function getValue (frame:Number) :Number {
			
			if(frame > totalframes) {
				if(loop) {
					var f:int = int(frame/totalframes);
					frame = frame/totalframes-f == 0 ? totalframes : frame - (totalframes*f);
				}else{
					frame = totalframes;
				}
			}else if(frame < 1) {
				frame = 1;
			}
			
			return timeline[frame-1];
		}
		
		
	}
	
}